<template>
	<view class="pre-sale-info" v-if="sale_type === 20">
		<view class="item" v-if="hasUseDateTips">
			<image :src="`${imgBaseUrl}rili-icon.png`" class="item-icon" />
			<text class="text">{{ use_date_tips.title }}：{{ use_date_tips.content }}</text>
		</view>
		<view class="item" v-if="hasUseWeekTips">
			<image :src="`${imgBaseUrl}time-icon.png`" class="item-icon" />
			<text class="text">{{ use_week_tips.title }}：{{ use_week_tips.content }}</text>
		</view>
		<view class="item" v-if="hasUseTimeTips">
			<image :src="`${imgBaseUrl}date-icon.png`" class="item-icon" />
			<text class="text">{{ use_time_tips.title }}：{{ use_time_tips.content }}</text>
		</view>
	</view>
</template>

<script setup lang="ts">
interface SaleTipsData {
	title: string
	content: string
}

interface PreSaleInfoProps {
	// 销售类型 10-日历票 20-预售票
	sale_type: 10 | 20
	use_date_tips: SaleTipsData
	use_week_tips: SaleTipsData
	use_time_tips: SaleTipsData
}

import { computed } from "vue"
const imgBaseUrl = inject("imgBaseUrl")

const props = defineProps<PreSaleInfoProps>()

const hasUseDateTips = computed(() => !!props.use_date_tips)
const hasUseWeekTips = computed(() => !!props.use_week_tips)
const hasUseTimeTips = computed(() => !!props.use_time_tips)
</script>

<style lang="scss" scoped>
.pre-sale-info {
	margin-top: 16rpx;
	padding: 20rpx 16rpx;
	background: #f7f8fa;
	border-radius: 16rpx;

	.item {
		display: flex;
		align-items: center;
		margin-bottom: 16rpx;

		&:last-child {
			margin-bottom: 0;
		}

		.item-icon {
			width: 28rpx;
			height: 28rpx;
		}

		.text {
			margin-left: 12rpx;
			font-size: 24rpx;
			color: #86909c;
			line-height: 36rpx;
		}
	}
}
</style>
